import shap
from tensorflow import keras
from sklearn.model_selection import train_test_split

shap.initjs()

X_train,y_train,X_test,y_test = train_test_split(data_input, data_result, test_size=0.01, random_state=0)
model_path = "tongji-1.0-1-5.h5"
model = keras.models.load_model(model_path)

explainer = shap.GradientExplainer(model)
shap_values = explainer.shap_values(X_train)
# visualize the first prediction's explanation (use matplotlib=True tavoid Javascript)
shap.force_plot(explainer.expected_value[1], shap_values[1][11], X_train.iloc[11,:])
shap.summary_plot(shap_values[1],X_train,max_display=40)